home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / ecstr1.arc / STRCSPN.C < prev    next >
C/C++ Source or Header  |  1987-03-04  |  674b  |  26 lines

  1. /*  File   : strcspn.c
  2.     Author : Richard A. O'Keefe.
  3.     Updated: 11 April 1984
  4.     Defines: strspn()
  5.  
  6.     strcspn(s1, s2) returns the length  of  the  longest  prefix  of  s1
  7.     consisting  entirely  of  characters  which  are  NOT  in s2 ("c" is
  8.     "complement").  NUL is considered to be part  of  s2.   As  _str2set
  9.     will never include NUL in a set, we have to check for it explicitly.
  10. */
  11.  
  12. #include "strings.h"
  13. #include "_str2set.h"
  14.  
  15. int strcspn(str, set)
  16.     register _char_ *str;
  17.     char *set;
  18.     {
  19.        register int L;
  20.  
  21.        _str2set(set);
  22.        for (L = 0; *str && _set_vec[*str++] != _set_ctr; L++) ;
  23.        return L;
  24.     }
  25.  
  26.